<?php
!defined('DS') && define('DS', DIRECTORY_SEPARATOR);
!defined('ROOT_PATH') && define('ROOT_PATH', realpath(dirname(dirname(__FILE__))));
!defined('FILE_STATIC_PATH') && define('FILE_STATIC_PATH', ROOT_PATH . DS . 'static');
!defined('PLATFORM_PATH') && define('PLATFORM_PATH', ROOT_PATH . DS . 'platform');
!defined('PLATFORM_T3_PATH') && define('PLATFORM_T3_PATH', PLATFORM_PATH . DS . 'vendor');
!defined('PLATFORM_SRC_PATH') && define('PLATFORM_SRC_PATH', PLATFORM_PATH . DS . 'src');
!defined('PLATFORM_CONTROLLER_PATH') && define('PLATFORM_CONTROLLER_PATH', PLATFORM_SRC_PATH . DS . 'controllers');
!defined('PLATFORM_SERVICE_PATH') && define('PLATFORM_SERVICE_PATH', PLATFORM_SRC_PATH . DS . 'services');
!defined('PLATFORM_MODEL_PATH') && define('PLATFORM_MODEL_PATH', PLATFORM_SRC_PATH . DS . 'models');
!defined('PLATFORM_LIB_PATH') && define('PLATFORM_LIB_PATH', PLATFORM_SRC_PATH . DS . 'library');
!defined('PLATFORM_PLUGINS_PATH') && define('PLATFORM_PLUGINS_PATH', PLATFORM_SRC_PATH . DS . 'plugins');
!defined('PLATFORM_LISTENERS_PATH') && define('PLATFORM_LISTENERS_PATH', PLATFORM_SRC_PATH . DS . 'listeners');
!defined('PLATFORM_CONFIG_PATH') && define('PLATFORM_CONFIG_PATH', PLATFORM_SRC_PATH . DS . 'config');
!defined('ROOT_NAMESPACE') && define('ROOT_NAMESPACE', 'StarCloud');
!defined('ACM_CONFIG_PATH') && define('ACM_CONFIG_PATH', '/home/www/config');

date_default_timezone_set('Asia/Shanghai');
mb_internal_encoding('utf-8');
mb_regex_encoding('utf-8');

require PLATFORM_T3_PATH . DS . 'autoload.php'; // 加载composer外部依赖

$platformLoader = new \Phalcon\Loader();
$platformLoader->registerNamespaces([
    'StarCloud\Controllers' => PLATFORM_CONTROLLER_PATH,
    'StarCloud\Services' => PLATFORM_SERVICE_PATH,
    'StarCloud\Models' => PLATFORM_MODEL_PATH,
    'StarCloud\Library' => PLATFORM_LIB_PATH,
    'StarCloud\Plugins' => PLATFORM_PLUGINS_PATH,
    'StarCloud\Listeners' => PLATFORM_LISTENERS_PATH,
]);
$platformLoader->register();

!defined('ENVIRONMENT') && define('ENVIRONMENT', 'development'); // 三种环境 development | debug | production (staging)

$config = \Framework\Library\Tool::getConfig(PLATFORM_CONFIG_PATH, 'test_config');
$di = require PLATFORM_CONFIG_PATH . DS . 'test_services.php';

return new \Phalcon\Mvc\Application($di);
